home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / sftgrd / 2_groups.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1996-06-12  |  7.1 KB  |  244 lines

  1. VERSION 2.00
  2. Begin Form fmtTwoGroups 
  3.    BorderStyle     =   1  'Fixed Single
  4.    Caption         =   "Two Groups"
  5.    ClientHeight    =   5820
  6.    ClientLeft      =   1095
  7.    ClientTop       =   1485
  8.    ClientWidth     =   7365
  9.    Height          =   6225
  10.    Left            =   1035
  11.    LinkTopic       =   "Form7"
  12.    MaxButton       =   0   'False
  13.    MinButton       =   0   'False
  14.    ScaleHeight     =   5820
  15.    ScaleWidth      =   7365
  16.    Top             =   1140
  17.    Width           =   7485
  18.    Begin CommandButton cmdCancel 
  19.       Cancel          =   -1  'True
  20.       Caption         =   "Cancel"
  21.       Default         =   -1  'True
  22.       Height          =   495
  23.       Left            =   3120
  24.       TabIndex        =   7
  25.       Top             =   4800
  26.       Width           =   1215
  27.    End
  28.    Begin CommandButton cmdOK 
  29.       Caption         =   "OK"
  30.       Height          =   495
  31.       Left            =   3120
  32.       TabIndex        =   6
  33.       Top             =   4080
  34.       Width           =   1215
  35.    End
  36.    Begin CommandButton cmdRemoveAll 
  37.       Caption         =   "Remove All"
  38.       Height          =   495
  39.       Left            =   3120
  40.       TabIndex        =   4
  41.       Top             =   2760
  42.       Width           =   1215
  43.    End
  44.    Begin CommandButton cmdRemove 
  45.       Caption         =   "<== Remove"
  46.       Height          =   495
  47.       Left            =   3120
  48.       TabIndex        =   3
  49.       Top             =   1800
  50.       Width           =   1215
  51.    End
  52.    Begin CommandButton cmdAdd 
  53.       Caption         =   "Add  ==>"
  54.       Height          =   495
  55.       Left            =   3120
  56.       TabIndex        =   2
  57.       Top             =   840
  58.       Width           =   1215
  59.    End
  60.    Begin ListBox lstRight 
  61.       Height          =   4905
  62.       Left            =   4800
  63.       MultiSelect     =   2  'Extended
  64.       TabIndex        =   1
  65.       Top             =   600
  66.       Width           =   2295
  67.    End
  68.    Begin ListBox lstLeft 
  69.       Height          =   4905
  70.       Left            =   360
  71.       MultiSelect     =   2  'Extended
  72.       Sorted          =   -1  'True
  73.       TabIndex        =   0
  74.       Top             =   600
  75.       Width           =   2295
  76.    End
  77.    Begin Label lblRight 
  78.       Alignment       =   2  'Center
  79.       BackColor       =   &H00C0C0C0&
  80.       BorderStyle     =   1  'Fixed Single
  81.       Caption         =   "lblRight"
  82.       FontBold        =   -1  'True
  83.       FontItalic      =   0   'False
  84.       FontName        =   "MS Sans Serif"
  85.       FontSize        =   8.25
  86.       FontStrikethru  =   0   'False
  87.       FontUnderline   =   -1  'True
  88.       Height          =   375
  89.       Left            =   4800
  90.       TabIndex        =   9
  91.       Top             =   240
  92.       Width           =   2295
  93.    End
  94.    Begin Label lblLeft 
  95.       Alignment       =   2  'Center
  96.       BackColor       =   &H00C0C0C0&
  97.       BorderStyle     =   1  'Fixed Single
  98.       Caption         =   "lblLeft"
  99.       FontBold        =   -1  'True
  100.       FontItalic      =   0   'False
  101.       FontName        =   "MS Sans Serif"
  102.       FontSize        =   8.25
  103.       FontStrikethru  =   0   'False
  104.       FontUnderline   =   -1  'True
  105.       Height          =   375
  106.       Left            =   360
  107.       TabIndex        =   8
  108.       Top             =   240
  109.       Width           =   2295
  110.    End
  111.    Begin Label lblExitStatus 
  112.       Caption         =   "ExitStatus"
  113.       Height          =   495
  114.       Left            =   3120
  115.       TabIndex        =   5
  116.       Top             =   5280
  117.       Visible         =   0   'False
  118.       Width           =   1215
  119.    End
  120. ': 2_GROUPS.FRM
  121. '-    Manage what is in two groups
  122. ' Copyright 1994, AA-Software International
  123. '     Distributed for non-commercial educational use only.
  124. '     For other use contact:
  125. '        AA-Software International
  126. '        12 ter Domaine Du Bois Joli
  127. '        06330 Roquefort-Les-Pins, France
  128. '        Tel: (+33) 93.77.50.47
  129. '        Fax: (+33) 93.77.19.78
  130. '        Internet: cswilly@acm.org
  131. '        CompuServe: 100343,2570
  132. Option Explicit
  133. Sub cmdAdd_Click ()
  134.    pAddToRight
  135. End Sub
  136. Sub cmdCancel_Click ()
  137.    lblExitStatus.Caption = "CANCEL"
  138.    Me.Hide
  139. End Sub
  140. Sub cmdOK_Click ()
  141.    lblExitStatus.Caption = "OK"
  142.    Me.Hide
  143. End Sub
  144. Sub cmdRemove_Click ()
  145.    pAddToLeft
  146. End Sub
  147. Sub cmdRemoveAll_Click ()
  148.    Dim itemKtr_i As Integer
  149.    'Move all items from Right group to Left group
  150.    For itemKtr_i = 0 To lstRight.ListCount - 1
  151.       lstLeft.AddItem lstRight.List(itemKtr_i)
  152.    Next itemKtr_i
  153.    'Remove All Groups from In-favor list
  154.    lstRight.Clear
  155.    pSetRemoveAllButton
  156.    pSetFocus lstRight, lstLeft
  157. End Sub
  158. Sub Form_Activate ()
  159.    pSetRemoveAllButton
  160.    pSetFocus lstLeft, lstRight
  161. End Sub
  162. Sub Form_Load ()
  163.    cmdAdd.Enabled = False
  164.    cmdRemove.Enabled = False
  165. End Sub
  166. Sub lstLeft_Click ()
  167.    cmdAdd.Enabled = True
  168.    cmdRemove.Enabled = False
  169. End Sub
  170. Sub lstLeft_DblClick ()
  171.    pAddToRight
  172. End Sub
  173. Sub lstRight_Click ()
  174.    cmdAdd.Enabled = False
  175.    cmdRemove.Enabled = True
  176. End Sub
  177. Sub lstRight_DblClick ()
  178.    pAddToLeft
  179. End Sub
  180. Private Sub pAddToLeft ()
  181.    pMoveItem lstRight, lstLeft
  182. End Sub
  183. Private Sub pAddToRight ()
  184.    pMoveItem lstLeft, lstRight
  185. End Sub
  186. Private Sub pMoveItem (lstFrom As Control, lstTo As Control)
  187.    Dim insertPoint_i As Integer
  188.    insertPoint_i = lstTo.ListIndex + 1
  189.    If insertPoint_i > lstTo.ListCount Then insertPoint_i = lstTo.ListCount
  190.    Dim itemKtr_i As Integer
  191.    'Copy from lstFrom to lstTo
  192.    For itemKtr_i = 0 To lstFrom.ListCount - 1
  193.       If lstFrom.Selected(itemKtr_i) Then
  194.          lstTo.AddItem lstFrom.List(itemKtr_i), insertPoint_i
  195.          insertPoint_i = insertPoint_i + 1
  196.       End If
  197.    Next itemKtr_i
  198.    'Remove from lstFrom
  199.    itemKtr_i = 0
  200.    Do While itemKtr_i < lstFrom.ListCount
  201.       If lstFrom.Selected(itemKtr_i) Then
  202.          lstFrom.RemoveItem (itemKtr_i)
  203.       Else
  204.          itemKtr_i = itemKtr_i + 1
  205.       End If
  206.       
  207.    Loop
  208.    lstTo.Selected(lstTo.ListIndex) = False
  209.    lstTo.ListIndex = insertPoint_i - 1
  210.    lstTo.Selected(lstTo.ListIndex) = True
  211.    pSetRemoveAllButton
  212.    pSetFocus lstFrom, lstTo
  213. End Sub
  214. Private Sub pSetFocus (c1 As Control, c2 As Control)
  215.    If c1.ListCount = 0 Then
  216.       'clear select flag
  217.       Dim listKtr_i As Integer
  218.       For listKtr_i = 0 To c2.ListCount - 1
  219.          c2.Selected(listKtr_i) = False
  220.       Next listKtr_i
  221.       'Select first item
  222.       c2.ListIndex = 0
  223.       c2.Selected(c2.ListIndex) = True
  224.       c2.SetFocus
  225.       Exit Sub
  226.    End If
  227.    If c1.ListIndex >= 0 Then
  228.       'Select the current items
  229.       c1.Selected(c1.ListIndex) = True
  230.    Else
  231.       'Must have fallen off the end of the list Select the last items
  232.       c1.ListIndex = c1.ListCount - 1
  233.       c1.Selected(c1.ListIndex) = True
  234.    End If
  235.    c1.SetFocus
  236. End Sub
  237. Private Sub pSetRemoveAllButton ()
  238.    If lstRight.ListCount > 1 Then
  239.       cmdRemoveAll.Enabled = True
  240.    Else
  241.       cmdRemoveAll.Enabled = False
  242.    End If
  243. End Sub
  244.